package cn.edu.cqupt.cxcy.action;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.edu.cqupt.cxcy.dto.AdminImpl;
import cn.edu.cqupt.cxcy.dto.IndexImpl;
import cn.edu.cqupt.cxcy.model.Investor;


/**
 * 管理员后台主页
 * @author Dancer-mno
 * @date 2015年10月17日
 */
public class AdminAddInveInfo extends HttpServlet {
	private static final long serialVersionUID = 1L;
	
	@Override
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		this.doPost(request, response);
	}
	
	@Override
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		// /admin/addInve
		String name  = request.getParameter("name");//用户名
		String loname  = request.getParameter("loname");//登陆名
		String tel = request.getParameter("tel");//电话
		String addr = request.getParameter("addr");//地址
		String explain = request.getParameter("explain");//简介
		if(loname!=null && !loname.equals("") && new IndexImpl().usernameIsUnique(loname)) {
			Investor inve = new Investor();
			inve.setI_name(name);
			inve.setI_loname(loname);
			inve.setI_tel(tel);
			inve.setI_addr(addr);
			inve.setI_explain(explain);
			new AdminImpl().addInve(inve);
		}
		response.sendRedirect(request.getHeader("referer"));
	}

}
